package com.tehui.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tehui.R;
import com.tehui.bean.BrandData;
import com.tehui.utils.ui.UiUtils;

import java.util.List;

import static com.tehui.app.MyApplication.IS_TAOKE;

/**
 * Created by jasmine on 2017/7/24.
 */

public class MoodsAdapter extends BaseQuickAdapter<BrandData.ResultBean, BaseViewHolder> {
    private final RequestOptions             options;
    public MoodsAdapter(@Nullable List<BrandData.ResultBean> data) {
        super(R.layout.item_moods_layout,data);
        if (IS_TAOKE) {
            options = new RequestOptions().centerCrop().placeholder(R.drawable.sd);
        } else {
            options = new RequestOptions().centerCrop().placeholder(R.drawable.sds);
        }
    }

    @Override
    protected void convert(BaseViewHolder helper, BrandData.ResultBean item) {
        helper.setText(R.id.tvTitle,item.D_title)
                .setText(R.id.money,"¥" + item.Price)
                .setText(R.id.num,"优惠券¥" + item.Quan_price)
                .setText(R.id.salenum,"销量" + item.Sales_num)
                .setText(R.id.sort,helper.getLayoutPosition() + 1 +"");
            Glide.with(UiUtils.getContext()).load(item.Pic.trim()).apply(options).transition(new DrawableTransitionOptions().crossFade(300)).into((ImageView) helper.getView(R.id.img));
    }
}
